package com.ruoyi.appService.mentalTestResult.huolandResult.controller;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.appService.mentalTestResult.mbtiResult.domain.ZTestMbtiTestresult;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.appService.mentalTestResult.huolandResult.domain.ZTestHuolandTestresult;
import com.ruoyi.appService.mentalTestResult.huolandResult.service.IZTestHuolandTestresultService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 霍兰德测试结果Controller
 * 
 * @author anjiao
 * @date 2025-05-15
 */
@RestController
@RequestMapping("/mentalTest/huolandTestResult")
public class ZTestHuolandTestresultController extends BaseController
{
    @Autowired
    private IZTestHuolandTestresultService zTestHuolandTestresultService;

    /**
     * 查询霍兰德测试结果列表
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:huolandTestResult:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZTestHuolandTestresult zTestHuolandTestresult)
    {
        startPage();
        List<ZTestHuolandTestresult> list = zTestHuolandTestresultService.selectZTestHuolandTestresultList(zTestHuolandTestresult);
        return getDataTable(list);
    }

    /**
     * 导出霍兰德测试结果列表
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:huolandTestResult:export')")
    @Log(title = "霍兰德测试结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZTestHuolandTestresult zTestHuolandTestresult)
    {
        List<ZTestHuolandTestresult> list = zTestHuolandTestresultService.selectZTestHuolandTestresultList(zTestHuolandTestresult);
        ExcelUtil<ZTestHuolandTestresult> util = new ExcelUtil<ZTestHuolandTestresult>(ZTestHuolandTestresult.class);
        util.exportExcel(response, list, "霍兰德测试结果数据");
    }

    /**
     * 获取霍兰德测试结果详细信息
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:huolandTestResult:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zTestHuolandTestresultService.selectZTestHuolandTestresultById(id));
    }

    /**
     * 新增霍兰德测试结果
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:huolandTestResult:add')")
    @Log(title = "霍兰德测试结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZTestHuolandTestresult zTestHuolandTestresult)
    {
        return toAjax(zTestHuolandTestresultService.insertZTestHuolandTestresult(zTestHuolandTestresult));
    }

    /**
     * 修改霍兰德测试结果
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:huolandTestResult:edit')")
    @Log(title = "霍兰德测试结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZTestHuolandTestresult zTestHuolandTestresult)
    {
        return toAjax(zTestHuolandTestresultService.updateZTestHuolandTestresult(zTestHuolandTestresult));
    }

    /**
     * 删除霍兰德测试结果
     */
    @PreAuthorize("@ss.hasPermi('mentalTest:huolandTestResult:remove')")
    @Log(title = "霍兰德测试结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zTestHuolandTestresultService.deleteZTestHuolandTestresultByIds(ids));
    }


    // 给小程序端提供的新增或修改测试结果
    @PostMapping("addOrUpdate")
    public AjaxResult addOrupdateTestResult(@RequestBody ZTestHuolandTestresult zTestHuolandTestresult, HttpServletRequest request)
    {
        zTestHuolandTestresultService.addOrupdateTestResult(zTestHuolandTestresult,request);
        return AjaxResult.success();
    }


    //    查询测试结果根据用户id
    @PostMapping("selectTestResult")
    public AjaxResult selectTestResult( HttpServletRequest request)
    {
        return zTestHuolandTestresultService.selectTestResult(request);
    }


}
